<?php

namespace common\models\user;

use Yii;

/**
 * This is the model class for table "{{%user_account_orange_record}}".
 *
 * @property int $id
 * @property int $user_id 用户Id
 * @property int $balance 收支 -1支出  1收入
 * @property int $value 具体数额
 * @property string $model 来源关联模型
 * @property int $model_id 来源关联模型id
 * @property string $auth_token 校验规则
 * @property string $ip ip
 * @property string $mark 备注
 * @property int $created_at 创建时间
 * @property int $updated_at 更新时间
 * @property int $deleted_at 删除时间
 */
class UserAccountOrangeRecord extends \yii\db\ActiveRecord {

    use \common\traits\TimestampBehavior;

    const BALANCE_INCREASE = 1; //增加
    const BALANCE_REDUCE = -1; //减少

    /**
     * @inheritdoc
     */

    public static function tableName() {
        return '{{%user_account_orange_record}}';
    }

    /**
     * @inheritdoc
     */
    public function rules() {
        return [
            [['user_id', 'value', 'model_id', 'created_at', 'updated_at', 'deleted_at'], 'integer'],
            [['model'], 'required'],
            [['balance'], 'integer', 'max' => 1],
            [['model', 'auth_token', 'ip'], 'string', 'max' => 32],
            [['mark'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'user_id' => '用户Id',
            'balance' => '收支 -1支出  1收入',
            'value' => '具体数额',
            'model' => '来源关联模型',
            'model_id' => '来源关联模型id',
            'auth_token' => '校验规则',
            'ip' => 'ip',
            'mark' => '备注',
            'created_at' => '创建时间',
            'updated_at' => '更新时间',
            'deleted_at' => '删除时间',
        ];
    }

}
